<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>视频信息管理系统-视频管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="author" content="Bluth Company">
    <link rel="shortcut icon" href="__STATIC__/assets/ico/favicon.html">
    <link href="__STATIC__/assets/css/bootstrap.css" rel="stylesheet">
    <link href="__STATIC__/assets/css/theme.css" rel="stylesheet">
    <link href="__STATIC__/assets/css/font-awesome.min.css" rel="stylesheet">
    <link href="__STATIC__/assets/css/alertify.css" rel="stylesheet">
    <link rel="Favicon Icon" href="favicon.ico">
 
  </head>
  <body>
    <div id="wrap">
    {include    file="public:header"   /}
    

    <div class="container-fluid">

     {include    file="public:sidemenu"   /}

      <!-- Main window -->
      <div class="main_container" id="users_page">

        <div class="row-fluid">
          <ul class="breadcrumb">
            <li><a href="#">首页</a> <span class="divider">/</span></li>
            <li class="active">视频管理</li>
          </ul>

        <div class="row-fluid">
          <div class="widget widget-padding span12">
            <div class="widget-header">
              <i class="icon-group"></i>
              <h5>视频列表</h5>
              <div class="widget-buttons">
                  <a href="#" data-title="Add User" data-toggle="modal" data-target="#example_modal"><i class="icon-plus"></i></a>
                  <a href="#" data-title="Collapse" data-collapsed="false" class="collapse"><i class="icon-chevron-up"></i></a>
              </div>
            </div>  
            <div class="widget-body">
              <table id="users" class="table table-striped table-bordered dataTable">
                <thead>
		<tr>
			<th>编号</th>
			<th>采摘园名</th>
			<th>图片</th>
			<th>类型</th>
			<th>开园时间</th>
			<th></th>
		</tr>
                </thead>
                <tbody>
		{volist name="gardens" id="vo"}

                  <tr>
                    <td>{$i}</td>
			<td>{$vo.name}</td>
			<td><img src="__STATIC__/posters/{$vo.pic}" style="width:100px"></td>
			<td>{$vo.typename}</td>
			<td>{$vo.opentime}</td>
                    <td>
                      <div class="btn-group">
                        <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
                        Action
                          <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu pull-right">
                          <li><a href="#" data-toggle="modal" data-target="#edit_modal" onclick="jsedit({$vo.id})"><i class="icon-edit"></i> Edit</a></li>
                          <li><a href="{:url('delete',['id'=>$vo.id])}"><i class="icon-trash"></i> Delete</a></li>
                        </ul>
                      </div>
                    </td>
                  </tr>
    {/volist}              
                </tbody>
              </table>
            </div> <!-- /widget-body -->
          </div> <!-- /widget -->
        </div> <!-- /row-fluid -->

      </div>
      <!-- /Main window -->

    </div><!--/.fluid-container-->
    </div><!-- wrap ends-->

    <!-- Example Modal -->
    <div id="example_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">添加视频信息</h3>
      </div>
      <div class="modal-body">
        <p>
<form  method="POST" action="{:url('add')}" enctype="multipart/form-data">

  <div class="form-group">
    <label for="videoname" class="col-md-2 col-xs-2 control-label">视频名称</label>
    <div class="col-md-10 col-xs-10">
      <input type="text" class="form-control" placeholder="videoname" name="videoname" required>
    </div>
  </div>

    <div class="form-group">
    <label  class="col-md-2 col-xs-2 control-label">视频类型</label>
    <div class="col-md-10 col-xs-10">
    <select class="form-control" name="videotype" >

  {volist name="types" id="vo"}
  <option value='{$vo.tid}'>{$vo.typename}</option>
  {/volist}
</select> 
    </div>
  </div>
  
<div class="form-group">
    <label  class="col-md-2 col-xs-2 control-label">视频海报</label>
    <div class="col-md-10 col-xs-10">
    <input type="hidden" name="MAX_FILE_SIZE" value="3000000">
        <input type="file" id="exampleInputFile" name="pic" required>
      </div>
  </div>


<div class="form-group">
<label  class="col-md-2 col-xs-2 control-label">视频简介</label>
    <div class="col-md-10 col-xs-10">
       <textarea class="form-control" rows="3" name="videointro"   required></textarea>
      </div>
</div>

 <div class="form-group">
    <label for="address" class="col-md-2 col-xs-2 control-label">下载地址</label>
    <div class="col-md-10 col-xs-10">
      <input type="text" class="form-control" id="address" placeholder="address" name="address" required>
    </div>
  </div>


    
  <div class="form-group">
    <div class="col-xs-offset-2 col-xs-10">
      <input type="submit" class="btn btn-default" value="添加">
     <input type="reset" class="btn btn-default" value="重置">
  </div>
  </div>
</form>      
        </p>
      </div>
      <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        <button class="btn btn-primary">Save changes</button>
      </div>
    </div>  
     <!-- Edit Modal -->
    <div id="edit_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">修改视频信息</h3>
      </div>
      <div class="modal-body">
        <p>
<form  method="POST" action="{:url('update')}" enctype="multipart/form-data">
<input type="hidden" name="vid" id="vid_edit">
  <div class="form-group">
    <label for="videoname" class="col-md-2 col-xs-2 control-label">视频名称</label>
    <div class="col-md-10 col-xs-10">
      <input type="text" class="form-control" placeholder="videoname" name="videoname" id="videoname_edit" required>
    </div>
  </div>

    <div class="form-group">
    <label  class="col-md-2 col-xs-2 control-label">视频类型</label>
    <div class="col-md-10 col-xs-10">
    <select class="form-control" name="videotype" id='type_edit'>

  {volist name="types" id="vo"}
  <option value='{$vo.tid}'>{$vo.typename}</option>
  {/volist}
</select> 
    </div>
  </div>
  
<div class="form-group">
    <label  class="col-md-2 col-xs-2 control-label">视频海报</label>
    <div class="col-md-10 col-xs-10">
    <input type="hidden" name="MAX_FILE_SIZE" value="3000000">
        <input type="file" id="exampleInputFile" name="pic" required>
        <input type="hidden" name="pic2" id="pic_edit2">
        <img src="__STATIC__/posters/20161213140301975.jpg" id="pic_edit" style="width:100px">
      </div>
  </div>


<div class="form-group">
<label  class="col-md-2 col-xs-2 control-label">视频简介</label>
    <div class="col-md-10 col-xs-10">
       <textarea class="form-control" rows="3" name="videointro" id="videointro_edit"   required></textarea>
      </div>
</div>

 <div class="form-group">
    <label for="address" class="col-md-2 col-xs-2 control-label">下载地址</label>
    <div class="col-md-10 col-xs-10">
      <input type="text" class="form-control" id="address_edit" placeholder="address" name="address" required>
    </div>
  </div>


    
  <div class="form-group">
    <div class="col-xs-offset-2 col-xs-10">
      <input type="submit" class="btn btn-default" value="修改">
     <input type="reset" class="btn btn-default" value="重置">
  </div>
  </div>
</form>      
        </p>
      </div>
      <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        <button class="btn btn-primary">Save changes</button>
      </div>
    </div> 
	{include    file="public:footer"   /}
  <script>
    function jsedit(vid){
      $.getJSON("{:url('edit')}",{"vid":vid},function(json){
        $("#videoname_edit").val(json.videoname);
        $("#address_edit").val(json.address);
        $("#videointro_edit").val(json.intro);
        $("#pic_edit").attr("src","__STATIC__/posters/"+json.pic);
        $("#type_edit option[value="+json.tid+"]").attr("selected","selected");
        $("#vid_edit").val(json.vid);
        $("#pic_edit2").val(json.pic);
      });
    }

  </script>
  </body>
</html>
